import datetime
import pickle
import pandas as pd
import threading
import os
from pao.data import process_db
from gov.data_process.data import DataProcess
from gov.data_process.tire_pressure.sim_TP_data import TP_Sim_Data
from apscheduler.schedulers.blocking import BlockingScheduler

class InsertData_TP(DataProcess):

    def __init__(self, db_addr, db_port, destination_loc):
        DataProcess.__init__(self, db_addr, db_port)
        self.destination_loc = destination_loc

    def tep_TP_monitoring(self):
        date = datetime.datetime.now()
        tp = TP_Sim_Data(date=date, db_addr=self.db_addr,
                         db_port=self.db_port, destination_loc=self.destination_loc)
        tp.insert_TP_monitoring()

    def gener_TP_monitoring(self):
        scheduler = BlockingScheduler()
        scheduler.add_job(self.tep_TP_monitoring, 'cron',
                          day_of_week='*', hour=0, minute=2, second=0)
        scheduler.start()
